<template>
	<!-- 设置主页 -->
	<view class="set">
		<!-- #ifdef APP-PLUS -->
		<top-set></top-set>
		<tab-top fixed="true" title="设置"></tab-top>
		<!-- #endif -->
		<view class="bg_01"></view>
		<view class="set_box">
			<!-- 个人资料 -->
			<view class="set_item" @tap="goSet('personal')">
				<view class="set_item_left">
					<text>个人资料</text>
				</view>
				<view class="set_item_reght">
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
			<!-- 身份认证 -->
			<view class="set_item" @tap="goAttestation(show)">
				<view class="set_item_left">
					<text>身份认证</text>
				</view>
				<view class="set_item_reght">
					<text>{{name}}</text>
					<image v-if="imgshow" class="yz" src="/static/icon/yz.png"></image>
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
			<!-- 添加银行卡 -->
			<view class="set_item" @tap="goBank">
				<view class="set_item_left">
					<text>添加银行卡</text>
				</view>
				<view class="set_item_reght">
					<text>{{bank||'未添加'}}</text>
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
			<!-- 健康证认证 -->
			<!-- <view class="set_item" @tap="goHealthy">
				<view class="set_item_left">
					<text>健康证认证</text>
				</view>
				<view class="set_item_reght">
					<text>{{healthy}}</text>
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view> -->
			<!-- 绑定微信 -->
			<view class="set_item" @tap="goweixin">
				<view class="set_item_left">
					<text>绑定微信</text>
				</view>
				<view class="set_item_reght">
					<text>{{weixin||'未绑定'}}</text>
					<image class="weixin" v-if="weixin" src="/static/icon/wx_icon.png"></image>
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
		</view>	
		<view class="bg_02"></view>
		<view class="set_box"> 
			<!-- 黑名单 -->
			<view class="set_item" @tap="blacklist">
				<view class="set_item_left">
					<text>黑名单</text>
				</view>
				<view class="set_item_reght">
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
			<!-- 意见反馈 -->
			<view class="set_item" @tap="goSet('feedback')"> 
				<view class="set_item_left">
					<text>意见反馈</text>
				</view>
				<view class="set_item_reght">
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
			<!-- 检测更新 -->
			<!-- #ifdef APP-PLUS -->
			<view class="set_item">
				<view class="set_item_left uni-clearfix">
					<view style="float: left;">检测更新</view>
					<view style="float: left; width: 6upx;height: 6upx;background-color: red; margin: 36upx 0 0 2upx;"></view>
				</view>
				<view class="set_item_reght" @tap="tapVersion">
					<text>V{{version}}</text>
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
			<!-- #endif -->
			
		</view>	
		<view class="bg_02" ref="dd"></view>
		<view class="set_box switcher">
			<!-- 身份切换 -->
			<view class="set_item" @tap="goSwitchIdentity">
				<view class="set_item_left">
					<text>身份切换</text>
				</view>
				<view class="set_item_reght">
					<text>我是保洁</text>
					<image src="/static/personal-center/right.png"></image>
				</view>
			</view>
		</view>
		<view class="button" @tap="logout()">退出账号</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				version:'',
				name:'',
				weixin:'',
				show:true,
				healthyShow:false,
				healthy:'未添加',
				bank:'',
				imgshow:false,
				user_auth:0
			}
		},
		onShow(){
			 // #ifdef APP-PLUS
			this.version  = plus.runtime.version;
			// #endif
			this.req({
				url:'user/accountInfo',
				method:"get",
				data:{
					id:this.isLogin().id
				}
			},(res)=>{
				console.log(res)
				if(res.data.status == 0){
					return;
				}
				//微信
				if(res.data.data.user_wx_info){
					this.weixin = res.data.data.user_wx_info.nick_name;
					this.wx = true;
				}
				//银行卡
				if(res.data.data.user_bank.length !== 0){
					this.bank = '已添加'
				}
				//地址
				if(res.data.data.user){
					//地址
					let info = res.data.data.user
					this.modifyUserInfo('address', info.address);
					this.updateUserInfo();
					
					//健康证
					if(info.handheld_photo){
						this.healthy = '已添加';
						this.healthyShow = true;
					}
					//认证信息
					this.user_auth = info.user_auth;
					if(info.user_auth == 0){
						this.name = "未认证"
						this.show = false;
						return;
					}
					if(info.user_auth == 2){
						this.name = "审核中"
						this.show = true;
						return;
					}
					if(info.user_auth == 3){
						this.name = "认证失败"
						this.show = false;
						return;
					}
					this.name = info.name;
					this.show = true;
					this.imgshow = true;
				}else{
					this.name = "未认证"
					this.show = false;
					return;
				}
			})
		},
		methods: {
			goSet(url) {
				/**
				 * 跳转set页面
				 */
				uni.navigateTo({
					url: '/pages/user/set/'+url
				});
			},
			goBank(){
				/**
				 * 跳转银行卡
				 */
				if(this.bank == '已添加'){
					return;
				}
				uni.navigateTo({
					url: '/pages/user/set/bank?auth=' + this.user_auth + '&name=' + this.name
				});
			},
			goweixin(){
				if(this.wx){
					return;
				}
				uni.navigateTo({
					url: '/pages/user/set/bind-wx'
				});
			},
			blacklist(){
				/**
				 * 跳转黑名单页面
				 */
				uni.navigateTo({
					url: '/pages/hotel/fans/blacklist'
				});
			},
			goAttestation(e) {
				if(e){
					return;
				}else{
					uni.navigateTo({
						url: '/pages/user/set/attestation'
					});
				}
			},
			goHealthy() {
				if(this.healthyShow){
					return;
				}else{
					uni.navigateTo({
						url: '/pages/user/set/healthy?auth=' + this.user_auth
					});
				}
			},
			goSwitchIdentity(){
				/**
				 * 跳转SwitchIdentity页面
				 */
				uni.navigateTo({
					url: '/pages/identity/switch-identity'
				});
			},
			tapVersion(){
				this.isApp();
			}
		}
	}
</script>

<style lang="scss" scoped>
.set{
	color: #333333;
	.set_box{
		width: 702upx;
		padding: 0 24upx;
		.set_item:nth-last-child(1){
			border-bottom: none;
		}
		.set_item{
			height: 98upx;
			border-bottom: 1upx solid #e5e5e5;
			line-height: 98upx;
			display: flex;
			justify-content: space-between;
			.set_item_left{
				font-size: 28upx;
			}
			.set_item_reght{
				font-size: 28upx;
				color: #999999;
				display: flex;
				align-items: center;
				.yz{
					width: 26upx;
					height: 26upx;
					margin-left:10upx;
					line-height: 26upx;
				}
				.weixin{
					width: 28upx;
					height: 28upx;
				}
				image{
					width: 12upx;
					height: 22upx;
					margin-left: 12upx;
				}
			}
		}
	}
	.switcher{
		height: 250upx;
	}
	.button{
		width: 540upx;
		height: 90upx;
		border-radius: 8upx;
		font-size: 28upx;
		line-height: 90upx;
		background-color: #f8f8f8;
		text-align: center;
		color: #333;
		margin: 0 auto;
	}
	.bg_01{
		width: 750upx;
		height: 30upx;
		background-color: #f0f0f0;
	}
	.bg_02{
		width: 750upx;
		height: 10upx;
		background-color: #f0f0f0;
	}
}
</style>
